﻿using BCCommon.Enums;
using BCEntity.Common.News.NewsContent;
using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace BCData.Common.News.NewsContent
{
    /// <summary>
    /// 新闻内容数据处理接口
    /// </summary> 
    public interface INewsContentData
    {
        /// <summary>
        /// 添加新闻内容
        /// </summary>
        /// <param name="entity">新闻内容</param>
        /// <returns></returns>
        NewsContentEntity Add(NewsContentEntity entity);
        /// <summary>
        /// 获取新闻内容列表总数
        /// </summary>
        /// <param name="contentCategoryId">分类Id</param>
        /// <param name="title">标题</param>
        /// <param name="keyWord">关键字</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="fromSim">来自后台查询</param>
        /// <returns></returns>
        int GetListCount(int? contentCategoryId, string title, string keyWord, DateTime? start, DateTime? end, bool fromSim);
        /// <summary>
        /// 获取新闻内容列表(分页)
        /// </summary>
        /// <param name="contentCategoryId">分类Id</param>
        /// <param name="title">标题</param>
        /// <param name="keyWord">关键字</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="ascending">排序</param>
        /// <param name="fromSim">来自后台查询</param>
        /// <param name="dataCount">数据总数</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页数据条数</param>
        /// <returns></returns>
        IEnumerable<NewsContentEntity> GetPageableList(int? contentCategoryId, string title, string keyWord, DateTime? start, DateTime? end, bool? ascending, bool fromSim, out int dataCount, int pageIndex, int pageSize);
        /// <summary>
        /// 获取新闻列表
        /// </summary>
        /// <param name="contentCategoryId">分类Id</param>
        /// <returns></returns>
        IEnumerable<NewsContentEntity> GetNewsList(int contentCategoryId);
        /// <summary>
        /// 获取内容列表
        /// </summary>
        /// <param name="contentCategoryId">内容分类ID</param>
        /// <param name="startIndex">起始下标</param>
        /// <param name="amount">数量</param>
        /// <returns></returns>
        IEnumerable<NewsContentEntity> GetContentListByIndexAndAmount(int contentCategoryId, int startIndex = 0, int amount = 0);
        /// <summary>
        /// 获取新闻内容
        /// </summary>
        /// <param name="newsContentId"></param>
        /// <returns></returns>
        IEnumerable<NewsContentEntity> GetNewById(long newsContentId);
        /// <summary>
        /// 获取新闻内容
        /// </summary>
        /// <param name="newsContentId">新闻内容Id</param>
        /// <param name="fromSim">来自后台查询</param>
        /// <returns></returns>
        NewsContentEntity GetNewsContentById(long newsContentId, bool fromSim);
        /// <summary>
        /// 获取上一篇或下一篇
        /// </summary>
        /// <param name="newsContentId">新闻内容Id</param>
        /// <param name="isNext">是否为下一篇</param>
        /// <returns></returns>
        NewsContentEntity GetNewsContentNextOrPreviou(long newsContentId, bool isNext);
        /// <summary>
        /// 获取新闻内容
        /// </summary>
        /// <param name="protocolType">协议类型</param>
        /// <returns></returns>
        NewsContentEntity GetNewsContentByProtocol(string protocolType);
        /// <summary>
        /// 修改新闻内容
        /// </summary>
        /// <param name="entity">新闻内容</param>
        /// <returns></returns>
        NewsContentEntity UpdateEntity(NewsContentEntity entity);
        /// <summary>
        /// 删除新闻内容
        /// </summary>
        /// <param name="newsContentId">新闻内容Id</param>
        /// <returns></returns>
        IEnumerable<NewsContentEntity> DeleteEntity(long newsContentId);
        /// <summary>
        /// 获取新闻内容视图（分页）
        /// </summary>
        /// <param name="contentCategoryId">分类Id</param>
        /// <param name="title">标题</param>
        /// <param name="keyWord">关键字</param>
        /// <param name="fromSim">来自后台查询</param>
        /// <param name="dataCount">数据总数</param>
        /// <param name="ascending">排序</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页数据条数</param>
        /// <returns></returns>
        IEnumerable<NewsContentViewEntity> GetViewPageableList(int? contentCategoryId, string title, string keyWord, bool fromSim, out int dataCount, bool? ascending, int pageIndex, int pageSize);
        /// <summary>
        /// 获取新闻内容Id列表
        /// </summary>
        /// <returns></returns>
        IEnumerable<long> GetNewsContentIds();
        /// <summary>
        /// 获取新闻总条数
        /// </summary>
        /// <returns></returns>
        int GetNewsCount();
        /// <summary>
        /// 更新浏览次数
        /// </summary>
        /// <param name="newsContentId">新闻Id</param>
        /// <returns></returns>
        bool UpdateViewsCount(long newsContentId);
        /// <summary>
        /// 更新点赞总数
        /// </summary>
        /// <param name="newsContentId">新闻Id</param>
        void UpdateLikeCount(long newsContentId);
        /// <summary>
        /// 更新评论总数
        /// </summary>
        /// <param name="newsContentId">新闻Id</param>
        void UpdateReplyCount(long newsContentId);
       
        /// <summary>
        /// 更新转发总数
        /// </summary>
        /// <param name="newsContentId">新闻Id</param>
        NewsContentEntity UpdateReprintCount(long newsContentId);

        /// <summary>
        /// 更新取消点赞次数
        /// </summary>
        /// <param name="newsContentId">新闻Id</param>
        void UpdateUnLikeCount(long newsContentId);

        /// <summary>
        /// 根据关键字查询新闻列表
        /// </summary>
        /// <param name="contentCategoryId">分类ID</param>
        /// <param name="keyWord">关键字</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页数据条数</param>
        /// <returns></returns>
        IEnumerable<NewsContentEntity> QueryNewsByKeyWord(int? contentCategoryId, string keyWord, out int dataCount, int pageIndex = 1, int pageSize = 20);
        /// <summary>
		/// 是否存在该记录
		/// </summary>
		/// <param name="newsContentId">新闻内容Id</param>
		Task<bool> Exists(long newsContentId);
        /// <summary>
		/// 启用新闻内容
		/// </summary>
		/// <param name="newsContentId">新闻内容Id</param>
		Task<bool> Enabled(long newsContentId);
        /// <summary>
        /// 禁用新闻内容
        /// </summary>
        /// <param name="newsContentId">新闻内容Id</param>
        Task<bool> Disabled(long newsContentId);
    }
}
